// @Author EthanScriptOn
// @Desc
package operator

import (
	"fmt"
	"gitee.com/fatzeng/srf_switch_basic_components/manager"
	"gitee.com/fatzeng/srf_switch_basic_components/switch_log"
)

var OperatorCenter = new(manager.ResourceManager)

func AddOperator(operatorInstance MultiChannelDataOperator) (err error) {
	if operatorInstance == nil {
		return fmt.Errorf("cannot add, MultiChannelDataOperator is nil")
	}
	return OperatorCenter.AddResource(operatorInstance)
}

func GetOperator(operatorIdentifier interface{}) MultiChannelDataOperator {
	resource := OperatorCenter.GetResource(operatorIdentifier)
	if resource == nil {
		switch_log.Logger().Error("GetOperator failed unable to obtain message is: ", operatorIdentifier)
		return nil
	}
	operatorInstance, ok := resource.(MultiChannelDataOperator)
	if ok {
		return operatorInstance
	}
	switch_log.Logger().Error("Not of type MultiChannelDataOperator message is: ", operatorIdentifier)
	return nil
}
